package group2assignone.ucm;

import group2assignone.dao.MyDAO;
import group2assignone.model.Flight;
import group2assignone.view.ListFlightsView;
import group2assignone.view.OurView;
import java.util.ArrayList;

/**
 *
 * @author group2
 */
public class UCListFlights implements UCController {

    private OurView view;
    private ArrayList<Flight> flightArray;

    /**
     * The customer is not logged in, a guest customer is created.
     * @param view
     */
    public UCListFlights(OurView view) {
        this.view = view;
    }

    /**
     * Use Case: Change UI to Search Flights
     * 1. system exits current view
     * 2. system updates gui to the search flights UI
     */
    public void run() {
        MyDAO coms = UCStartup.getInstance().getDAO();
        flightArray = coms.getFlights();
        ListFlightsView gui = new ListFlightsView(flightArray);
        gui.go();
        view.dispose();
    }
}
